import jdk.internal.org.objectweb.asm.tree.IntInsnNode;

public class LC0012 {
    public static void main(String[] args) {
        System.out.println(intToRoman(3749));
    }

    public static String intToRoman(int num) {
        String str = "";
        int i = 0;
        while (num > 0) {
            int a = num % 10;
            num = num / 10;
            str = getStr(a, i) + str;
            i++;
        }
        return str;
    }

    public static String getStr(int n, int i) {
        String str[] = {"I", "V", "X", "L", "C", "D", "M"};
        String res = "";
        if (n == 5) {
            res = str[i * 2 + 1];
        } else if (n < 5) {
            if (n == 4) {
                res = str[i * 2] + str[i * 2 + 1];
            } else {
                for (int j = 0; j < n; j++) {
                    res = res + str[i * 2];
                }
            }
        } else {
            if (n == 9) {
                res = str[i * 2] + str[i * 2 + 2];
            } else {
                res = str[i * 2 + 1];
                for (int j = 5; j < n; j++) {
                    res = res + str[i * 2];
                }
            }
        }
        return res;
    }
}
